package cn.tworice.config;

import cn.tworice.common.utils.AgingMap;
import org.mybatis.spring.annotation.MapperScan;
//import org.springframework.amqp.rabbit.annotation.EnableRabbit;
//import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
//import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@MapperScan("cn.tworice.**.dao")
@EnableTransactionManagement
//@EnableRabbit
public class AppConfig implements WebMvcConfigurer {

    /**
     * 自定义消息转换器，使用json格式进行序列化
     * @author 二饭
     * @email 1786705138@qq.com
     */
//    @Bean
//    public MessageConverter messageConverter() {
//        return new Jackson2JsonMessageConverter();
//    }

    /**
     * 放行静态文件
     * @author 二饭
     * @email 1786705138@qq.com
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
    }

    /**
     * 注入一个AgingMap
     * @author 二饭[tworice@sina.cn][2022/1/7 15:08]
     */
    @Bean
    public AgingMap<String,Object> addAgingMap(){
        return new AgingMap<String,Object>();
    }
}
